$(function () {
    vm.getStudents();
});

var vm = new Vue({
    el: '#mapp',
    data: {
        announcement: '欢迎来自安徽的周童小朋友,大家热烈欢迎~',
        bsnFirstStudent: {},
        bsnStudentList: {},
        bsnNotFinished: {},
        pageParams:{
			limit: "100",
			page: "1"
		},
        teacherNotice: '导师须知：导师应遵守平台的各项管理规定，不可随意取消预约等'
    },
    methods: {
    	getStudents: function() {
			$.get(ajaxServerUrlG("bsnstudent/infoByLoginParent"), function(r){
				if (r.code == 0) {
                	vm.bsnStudentList = r.page.list;
                	vm.bsnFirstStudent = vm.bsnStudentList[0];
                	//先装载学生信息，再装载预约
    				vm.getNotFinishedList();
				}
            });
    	},
        getNotFinishedList: function () { 
        	vm.pageParams.studentIds = [];
        	for (var idx in vm.bsnStudentList) {        		
        		vm.pageParams.studentIds.push(vm.bsnStudentList[idx].id)
        	}
        	console.log(vm.pageParams.studentIds);
            $.ajax({
                type: "POST",
                url: ajaxServerUrlG("bsngoutongzhidao/listByStudents"),
                contentType: "application/json",
                data: JSON.stringify(vm.pageParams),
                success: function (r) {
                    if (r.code === 0) {
                        vm.bsnNotFinished = r.list;
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
        gotoZhiDaoInfo: function(zhidaoId) {
			location.href = "parentZhiDaoInfo.html?id=" + zhidaoId;
		}
    },
    filters: {
        /*过滤并替换头像 */
        imgFilter: function (imgUrl, xingb) {
            // console.log(imgUrl);
            if (StringUtils.isNotEmpty(imgUrl)) {
                return imgUrl;
            }
            if (xingb == "男") {
                return "images/man@2x.png";
            } else {
                return "images/woman@2x.png";
            }
        }
    }
});

